package group.cyfc.studygo.controller.api;

import group.cyfc.studygo.dto.JsonResult;
import group.cyfc.studygo.service.UserRecordService;
import group.cyfc.studygo.vo.UserRecordVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 用户闯关记录控制器
 * @author Vonlin
 */
@Controller
@RequestMapping("/studygo/record")
public class UserRecordController {

    @Autowired
    private UserRecordService userRecordService;

    /**
     *
     * 保存用户闯关记录
     * @param userRecordVo
     * @return
     */
    @ApiOperation(value = "保存或更新用户的闯关记录",notes = "")
    @ApiImplicitParam(name = "userRecordVo",value = "一个Json,包含用户的雪花id,关卡的雪花id,关卡的年级，关卡的科目信息")
    @PutMapping(value = "/saveRecord")
    public ResponseEntity<JsonResult> saveRecord(@RequestBody UserRecordVo userRecordVo){
        JsonResult result = userRecordService.saveRecord(userRecordVo);
        return new ResponseEntity<>(result, result.getCode());
    }
}
